﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using Newtonsoft.Json;

namespace Cuando_Llega
{
    public partial class frmPrincipa : Form
    {
        public frmPrincipa()
        {
            InitializeComponent();
        }
        List<Linea> lineas = new List<Linea>();
        void cargar()
        {

            Linea l = new Linea();
            
                                l.value="101" ; l.idLinea="1,2"; lineas.Add(l); l = new Linea(); //101</option; lineas.Add(l); l = new Linea(); //
                                l.value="102" ; l.idLinea="3,4"; lineas.Add(l); l = new Linea(); //102</option; lineas.Add(l); l = new Linea(); //
                                l.value="103" ; l.idLinea="5,6"; lineas.Add(l); l = new Linea(); //103</option; lineas.Add(l); l = new Linea(); //
                                l.value="106" ; l.idLinea="7,8"; lineas.Add(l); l = new Linea(); //106</option; lineas.Add(l); l = new Linea(); //
                                l.value="107" ; l.idLinea="9,10"; lineas.Add(l); l = new Linea(); //107</option; lineas.Add(l); l = new Linea(); //
                                l.value="110" ; l.idLinea="11"; lineas.Add(l); l = new Linea(); //110</option; lineas.Add(l); l = new Linea(); //
                                l.value="112" ; l.idLinea="12,13"; lineas.Add(l); l = new Linea(); //112</option; lineas.Add(l); l = new Linea(); //
                                l.value="113" ; l.idLinea="14"; lineas.Add(l); l = new Linea(); //113</option; lineas.Add(l); l = new Linea(); //
                                l.value="115" ; l.idLinea="15"; lineas.Add(l); l = new Linea(); //115</option; lineas.Add(l); l = new Linea(); //
                                l.value="116" ; l.idLinea="16"; lineas.Add(l); l = new Linea(); //116</option; lineas.Add(l); l = new Linea(); //
                                l.value="120" ; l.idLinea="17"; lineas.Add(l); l = new Linea(); //120</option; lineas.Add(l); l = new Linea(); //
                                l.value="121" ; l.idLinea="18"; lineas.Add(l); l = new Linea(); //121</option; lineas.Add(l); l = new Linea(); //
                                l.value="122" ; l.idLinea="19,20"; lineas.Add(l); l = new Linea(); //122</option; lineas.Add(l); l = new Linea(); //
                                l.value="123" ; l.idLinea="21"; lineas.Add(l); l = new Linea(); //123</option; lineas.Add(l); l = new Linea(); //
                                l.value="125" ; l.idLinea="22"; lineas.Add(l); l = new Linea(); //125</option; lineas.Add(l); l = new Linea(); //
                                l.value="126" ; l.idLinea="23,24"; lineas.Add(l); l = new Linea(); //126</option; lineas.Add(l); l = new Linea(); //
                                l.value="127" ; l.idLinea="25"; lineas.Add(l); l = new Linea(); //127</option; lineas.Add(l); l = new Linea(); //
                                l.value="128" ; l.idLinea="26,27"; lineas.Add(l); l = new Linea(); //128</option; lineas.Add(l); l = new Linea(); //
                                l.value="129" ; l.idLinea="28"; lineas.Add(l); l = new Linea(); //129</option; lineas.Add(l); l = new Linea(); //
                                l.value="130" ; l.idLinea="29"; lineas.Add(l); l = new Linea(); //130</option; lineas.Add(l); l = new Linea(); //
                                l.value="131" ; l.idLinea="30"; lineas.Add(l); l = new Linea(); //131</option; lineas.Add(l); l = new Linea(); //
                                l.value="132" ; l.idLinea="31"; lineas.Add(l); l = new Linea(); //132</option; lineas.Add(l); l = new Linea(); //
                                l.value="133" ; l.idLinea="32,33"; lineas.Add(l); l = new Linea(); //133</option; lineas.Add(l); l = new Linea(); //
                                l.value="134" ; l.idLinea="34"; lineas.Add(l); l = new Linea(); //134</option; lineas.Add(l); l = new Linea(); //
                                l.value="135" ; l.idLinea="35"; lineas.Add(l); l = new Linea(); //135</option; lineas.Add(l); l = new Linea(); //
                                l.value="136" ; l.idLinea="36"; lineas.Add(l); l = new Linea(); //136</option; lineas.Add(l); l = new Linea(); //
                                l.value="137" ; l.idLinea="37"; lineas.Add(l); l = new Linea(); //137</option; lineas.Add(l); l = new Linea(); //
                                l.value="138" ; l.idLinea="38,39"; lineas.Add(l); l = new Linea(); //138</option; lineas.Add(l); l = new Linea(); //
                                l.value="139" ; l.idLinea="40,41"; lineas.Add(l); l = new Linea(); //139</option; lineas.Add(l); l = new Linea(); //
                                l.value="140" ; l.idLinea="43"; lineas.Add(l); l = new Linea(); //140</option; lineas.Add(l); l = new Linea(); //
                                l.value="141" ; l.idLinea="44"; lineas.Add(l); l = new Linea(); //141</option; lineas.Add(l); l = new Linea(); //
                                l.value="142" ; l.idLinea="45,46,47"; lineas.Add(l); l = new Linea(); //142</option; lineas.Add(l); l = new Linea(); //
                                l.value="143" ; l.idLinea="48,49"; lineas.Add(l); l = new Linea(); //143</option; lineas.Add(l); l = new Linea(); //
                                l.value="144" ; l.idLinea="50,51"; lineas.Add(l); l = new Linea(); //144</option; lineas.Add(l); l = new Linea(); //
                                l.value="145" ; l.idLinea="52,53"; lineas.Add(l); l = new Linea(); //145</option; lineas.Add(l); l = new Linea(); //
                                l.value="146" ; l.idLinea="54,55"; lineas.Add(l); l = new Linea(); //146</option; lineas.Add(l); l = new Linea(); //
                                l.value="153" ; l.idLinea="56,57,58"; lineas.Add(l); l = new Linea(); //153</option; lineas.Add(l); l = new Linea(); //
                                l.value="K" ; l.idLinea="64"; lineas.Add(l); l = new Linea(); //K</option; lineas.Add(l); l = new Linea(); //
                                l.value="LC" ; l.idLinea="65"; lineas.Add(l); l = new Linea(); //L&iacute;nea de la Costa</option; lineas.Add(l); l = new Linea(); //
                                l.value="RC" ; l.idLinea="66"; lineas.Add(l); l = new Linea(); //Ronda del Centro</option; lineas.Add(l); l = new Linea(); //
        }
        private void frmPrincipa_Load(object sender, EventArgs e)
        {
            cargar();
            cmbLinea.DataSource = lineas;
            cmbLinea.DisplayMember = "value";
        }

        private void cmbLinea_SelectedIndexChanged(object sender, EventArgs e)
        {
            WebClient wc = new WebClient();
            string strCalles = wc.DownloadString("http://www.etr.gov.ar/ajax/getData.php?accion=getCalle&idLinea=" + ((Linea)cmbLinea.SelectedItem).idLinea);

            List<Calle> calles = JsonConvert.DeserializeObject<List<Calle>>(strCalles);
            cmbCalle1.DataSource = calles;
            cmbCalle1.DisplayMember = "desc";
        }

        private void cmbCalle2_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void cmbCalle1_SelectedIndexChanged(object sender, EventArgs e)
        {
            WebClient wc = new WebClient();
            string strCalles = wc.DownloadString("http://www.etr.gov.ar/ajax/getData.php?accion=getInterseccion&idLinea=" + ((Linea)cmbLinea.SelectedItem).idLinea + "&idCalle=" + ((Calle)cmbCalle1.SelectedItem).id);

            List<Calle> calles = JsonConvert.DeserializeObject<List<Calle>>(strCalles);
            cmbCalle2.DataSource = calles;
            cmbCalle2.DisplayMember = "desc";
        }
    }
}
